import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { readFileSync } from 'fs';

const packageJson = JSON.parse(readFileSync('./package.json', { encoding: 'utf-8' }));
const globals = {
	...(packageJson?.dependencies || {}),
};

export default defineConfig({
	plugins: [react()],

	build: {
		// 输出文件夹
		outDir: 'dist',
		lib: {
			entry: './src/components/OriginButton.tsx',
			name: 'glow-gradient-button-react',
			formats: ['es', 'cjs'],
		},
		rollupOptions: {
			external: ['react', 'react-dom', ...Object.keys(globals)],
		},
	},
});
